import React, { Component } from 'react'

export default class Page2 extends Component {
    state = {
        val: ""
    }
    handleBlock(val) {
        if (val) {
            this.unBlock = this.props.history.block('文本还没有保存，确认是否跳转?')
        } else {
            this.unBlock && this.unBlock()
        }
    }
    componentWillUnmount() {
        this.unBlock && this.unBlock()
    }
    render() {
        return (
            <div>
                <textarea value={this.state.val} onChange={e => {
                    this.setState({ val: e.target.value })
                    this.handleBlock(e.target.value)
                }} />
            </div>
        )
    }
}
